package cn.org.atool.generator.demo.dm;

import org.test4j.module.database.annotations.ColumnDef;
import org.test4j.module.database.annotations.ScriptTable;
import org.test4j.module.database.datagen.BaseFactory;
import org.test4j.module.database.datagen.TableDataMap;
import org.test4j.tools.datagen.KeyValue;

/**
 * MyAddressDataMap: 表(实体)数据对比(插入)构造器
 *
 * @author Powered By Test4J
 */
@ScriptTable("home_address")
@SuppressWarnings({"unused"})
public class MyAddressDataMap extends TableDataMap<MyAddressDataMap> {
  @ColumnDef(
      value = "id",
      type = "BIGINT UNSIGNED",
      primary = true,
      autoIncrease = true,
      notNull = true
  )
  public final transient KeyValue<MyAddressDataMap> id = new KeyValue<>(this, "id", "id", supplier);

  @ColumnDef(
      value = "address",
      type = "VARCHAR(100)"
  )
  public final transient KeyValue<MyAddressDataMap> address = new KeyValue<>(this, "address", "address", supplier);

  @ColumnDef(
      value = "city",
      type = "VARCHAR(50)"
  )
  public final transient KeyValue<MyAddressDataMap> city = new KeyValue<>(this, "city", "city", supplier);

  @ColumnDef(
      value = "district",
      type = "VARCHAR(50)"
  )
  public final transient KeyValue<MyAddressDataMap> district = new KeyValue<>(this, "district", "district", supplier);

  @ColumnDef(
      value = "env",
      type = "VARCHAR(10)"
  )
  public final transient KeyValue<MyAddressDataMap> env = new KeyValue<>(this, "env", "env", supplier);

  @ColumnDef(
      value = "gmt_created",
      type = "DATETIME"
  )
  public final transient KeyValue<MyAddressDataMap> gmtCreated = new KeyValue<>(this, "gmt_created", "gmtCreated", supplier);

  @ColumnDef(
      value = "gmt_modified",
      type = "DATETIME"
  )
  public final transient KeyValue<MyAddressDataMap> gmtModified = new KeyValue<>(this, "gmt_modified", "gmtModified", supplier);

  @ColumnDef(
      value = "province",
      type = "VARCHAR(50)"
  )
  public final transient KeyValue<MyAddressDataMap> province = new KeyValue<>(this, "province", "province", supplier);

  @ColumnDef(
      value = "student_id",
      type = "BIGINT",
      notNull = true
  )
  public final transient KeyValue<MyAddressDataMap> studentId = new KeyValue<>(this, "student_id", "studentId", supplier);

  @ColumnDef(
      value = "tenant",
      type = "BIGINT",
      notNull = true,
      defaultValue = "0"
  )
  public final transient KeyValue<MyAddressDataMap> tenant = new KeyValue<>(this, "tenant", "tenant", supplier);

  @ColumnDef(
      value = "is_deleted",
      type = "TINYINT",
      defaultValue = "0"
  )
  public final transient KeyValue<MyAddressDataMap> isDeleted = new KeyValue<>(this, "is_deleted", "isDeleted", supplier);

  MyAddressDataMap(boolean isTable) {
    super("home_address", isTable);
  }

  MyAddressDataMap(boolean isTable, int size) {
    super("home_address", isTable, size);
  }

  /**
   * 创建MyAddressDataMap
   * 初始化主键和gmtCreate, gmtModified, isDeleted等特殊值
   */
  @Override
  public MyAddressDataMap init() {
    this.id.autoIncrease();
    this.isDeleted.values(false);
    return this;
  }

  public static MyAddressDataMap table() {
    return new MyAddressDataMap(true, 1);
  }

  public static MyAddressDataMap table(int size) {
    return new MyAddressDataMap(true, size);
  }

  public static MyAddressDataMap entity() {
    return new MyAddressDataMap(false, 1);
  }

  public static MyAddressDataMap entity(int size) {
    return new MyAddressDataMap(false, size);
  }

  public static class Factory extends BaseFactory<MyAddressDataMap> {
    public Factory() {
      super(MyAddressDataMap.class);
    }
  }
}
